package com.example.sm.mycook.task;

import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;

import com.example.sm.mycook.beans.HomeMyRVBean;
import com.example.sm.mycook.interfaceCallBack.HomeJsonCallBack;
import com.example.sm.mycook.tools.HttpUtils;

import java.util.List;

/**
 * Created by Administrator on 2016/12/6.
 */
public class HomeDataTask extends AsyncTask<String,Void,List<HomeMyRVBean>> {
    private Context context;
    private HomeJsonCallBack callBack;

    public HomeDataTask(HomeJsonCallBack callBack, Context context) {
        this.callBack = callBack;
        this.context = context;
    }

    @Override
    protected List<HomeMyRVBean> doInBackground(String... params) {
        String jsonString= HttpUtils.getStringData(params[0]);

        return ParseJsonHome.parseHomeData(jsonString);
    }

    @Override
    protected void onPostExecute(List<HomeMyRVBean> homeMyRVBeen) {
        super.onPostExecute(homeMyRVBeen);

//            Log.e("AAAA","集合已经不为空了"+homeMyRVBeen.get(0).getImgUrl());
            callBack.sendDataForHome(homeMyRVBeen);
    }
}
